<template><el-row style="height: 100%">
	<el-col :span="8" :offset="8"
		style="border-style: solid; border-color: #e6e6e6; margin-top: 5%; border-radius: 15px">
		<el-row>
			<el-col :span="16" :offset="4">
				<el-form label-width="100px">
					<h1>供应链金融应用</h1>
					<h3 style="margin: 10px 0">登录界面</h3>
					<el-form-item label="区块链地址:">
						<el-input type="primary" v-model="loginForm.address"></el-input>
					</el-form-item>
					<el-form-item label="组织类型:">
						<el-radio-group v-model="loginForm.orgType">
							<el-radio :label="1">公司</el-radio>
							<el-radio :label="2">银行</el-radio>
						</el-radio-group>
					</el-form-item>
				</el-form>
			</el-col>
		</el-row>
		<el-row style="margin-bottom: 20px">
			<el-button type="primary" @click="login">登录</el-button>
			<el-button type="primary" @click="register">注册</el-button>
		</el-row>
	</el-col>
</el-row></template>

<script>
export default {
	name: 'FrontMeLogin',

	data() {
		return {
			loginForm: {
				orgType: 1,
				address: '',
			},
		}
	},
	methods: {
		login() {
			if (this.loginForm.orgType == '') {
				this.$message.warning('区块链地址不能为空')
				return
			}
			if (this.loginForm.address == '') {
				this.$message.warning('用户类型不能为空')
				return
			}

			this.$axios.post('/finance/org/login', this.loginForm).then((res) => {
				if (res.code == 200) {
					this.$cookies.set('orgType', this.loginForm.orgType) // 设置cookie
					this.$cookies.set('address', this.loginForm.address)
					console.log('---Login Success---')
					this.$router.push('/home')
				}
			})
		},
		register() {
			this.$router.push('/')
		},
	},
}
</script>

<style lang="scss" scoped></style>
